# 导包
from api.reg import RegAPI
import random

# 创建测试类
class TestReg:

    # 创建测试方法
    def setup_class(self):
        self.reg = RegAPI()

    # 获取图片验证码成功（随机小数）
    def test01_get_img_code(self):
        response = self.reg.get_img_code(session=self.session,r="0."+str(random.randint(1,10000)))
        # print(response.status_code) #200
        # print(response.url)
        assert response.status_code == 200
    # 获取图片验证码成功（随机整数）
    def test02_get_img_code(self):
        response = self.reg.get_img_code(session=self.session,r=random.randint(1,10000))
        # print(response.status_code) #200
        # print(response.url)
        assert response.status_code == 200
    # 获取图片验证码失败（随机字符串）
    def test03_get_img_code(self):
        response = self.reg.get_img_code(session=self.session,r="abc")
        # print(response.status_code) #400
        # print(response.url)
        assert response.status_code == 400
    # 获取图片验证码失败（空）
    def test04_get_img_code(self):
        response = self.reg.get_img_code(session=self.session,r="")
        # print(response.status_code) #404
        # print(response.url)
        assert response.status_code == 404